<div class="section">

	<div class="section-title">Quản lý nhân viên</div>
    
    <div class="section-content">
    	
        <form action="" method="post" id="listitem" name="listitem">
        
        	<div class="button right">
            	<?php if($list_button['insert'] || $this->user->getUserTypeId()=="admin"){ ?>
            	<a class="button add" href="<?php echo $insert?>">Thêm mới</a>
                <?php } ?>
                <?php if($list_button['delete']|| $this->user->getUserTypeId()=="admin"){ ?>
                <a class="button delete" onclick="deleteItem()">Xóa</a>
                <?php } ?>
                <a class="button exit" href="?route=deliman/home">Về trang chủ</a>
            </div>
            
            <div class="clearer">^&nbsp;</div>
            
           	<div id="ben-search">
            <br />
            	<div class="left">
                    <label>Tên nhân viên:  </label>
                    <input type="text" id="hoten" name="hoten" class="text" />&nbsp;&nbsp;&nbsp;&nbsp; 
               	</div>
                <div class="left">
                    <label>Loại nhân viên:</label>
                    <select id="loainhanvienid" name="loainhanvienid">
                        <option value="">Chọn loại nhân viên</option>
                        <?php echo $cbloainhanvien?>
                    </select>&nbsp;&nbsp;&nbsp;&nbsp; 
                </div>
                <div class="left">
                    <label>Khu vực phụ trách</label>
                    <select id="khuvucphutrach" name="khuvucphutrach">
                        <option value="">Chọn khu vực</option>
                        <?php foreach($khuvucs as $khuvuc){ ?>
                        <option value="<?php echo $khuvuc['khuvucid']?>"><?php echo $this->string->getPrefix("&nbsp; &nbsp; &nbsp; &nbsp;",$khuvuc['level']);?><?php echo $khuvuc['tenkhuvuc']?></option>
                        <?php }?>
                    </select>&nbsp;&nbsp;&nbsp;&nbsp;         
                </div>
                <div class="left">
                    <a class="button-other search" onClick="searchForm()">Tìm kiếm</a>
                    <a class="button all" href="?route=deliman/nhanvien">Xem tất cả</a>
                </div>
            	<div class="clearer">^&nbsp;</div>
            </div>
            </div> 
            <div class="sitemap treeindex">
                <table class="data-table" cellpadding="0" cellspacing="0">
                <tbody>
                    <tr class="tr-head">
                        <th width="1%"><input class="inputchk" type="checkbox" onclick="$('input[name*=\'delete\']').attr('checked', this.checked);"></th>
                        
                        <th width="20%">Tên nhân viên</th>
                        <th width="8%">Giới tính</th>
                        <th width="18%">Địa chỉ</th>
                        <th width="18%">Email</th>
                        <th width="12%">Điện thoại</th>
                        <th>Tên loại nhân viên</th>
                        <th>Khu vực phụ trách</th>
                        <th>Control</th>                                  
                    </tr>
                    <?php if(count($datas)==0){ ?>
                    <tr>
                        <td colspan="9">
                        <div class="text-center">
                            <span class="thongbaokhongcodulieu">Không có dữ liệu trong hệ thống</span>
                        </div>
                        </td>
                    </tr>
                    <?php } ?>
        
        
        <?php
            foreach($datas as $item)
            {
        ?>
                    <tr>
                        <td class="check-column"><input class="inputchk" type="checkbox" name="delete[<?php echo $item['nhanvienid']?>]" value="<?php echo $item['nhanvienid']?>" ></td>
                        
                        <td><?php echo $item['hoten']?></td>
                        <td>
                        	<?php 
                            	echo ($item['gioitinh']==0)?"Nam":"Nữ"                         
                            ?>                        
                        </td>
                        <td><?php echo $item['diachi']?></td>
                        <td><?php echo $item['email']?></td>
                        <td><?php echo $item['dienthoai']?></td>
                        <td><?php echo $item['tenloainhanvien']?></td>
                        <td><?php echo $item['khuvucphutrach']?></td>
                        
                        <td class="link-control">
                        	<?php if($list_button['update']){ ?>
                        	<a class="button edit" href="<?php echo $item['link_edit']?>">Sửa</a>
                            <?php } ?>
                        </td>
                    </tr>
        <?php
            }
        ?>
                        
                                                    
                </tbody>
                </table>
            </div>
        	<?php echo $pager?>
        
        </form>
        
    </div>
    
</div>
<script language="javascript">
function deleteItem()
{
	var answer = confirm("Bạn có muốn xóa không?")
	if (answer)
	{
		$.post("?route=deliman/nhanvien/delete", 
				$("#listitem").serialize(), 
				function(data)
				{
					if(data=="true")
					{
						alert("Xóa thành công");
						window.location.reload();
					}
				}
		);
	}
}

function searchForm()
{
	var url =  "?route=deliman/nhanvien";
		
	if($("#hoten").val() != "")
		url += "&hoten="+ $("#hoten").val();
	if($("#loainhanvienid").val() != "")
		url += "&loainhanvienid=" + $("#loainhanvienid").val();
	if($("#khuvucphutrach").val() != "")
		url += "&khuvucphutrach=" + $("#khuvucphutrach").val();
	
	
	window.location = url;
}
// Giu cho cac field tim kiem van ko doi
$("#hoten").val("<?php echo urldecode($_GET['hoten'])?>");
$("#loainhanvienid").val("<?php echo $_GET['loainhanvienid']?>");
$("#khuvucphutrach").val("<?php echo $_GET['khuvucphutrach']?>");

</script>